package com.seth.myapplication.utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

/**
 * Created by Seth on 2017/12/5.
 */

public class DatabaseHelper extends SQLiteOpenHelper {
    private static final int VERSION = 1;
    private static final String DATABASE_NEME = "schoolhelp.db";


    public DatabaseHelper(Context context) {
        super(context, DATABASE_NEME, null, VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL("create table "+ CrimeTable.NAME + "("+
                CrimeTable.Cols.ID + " integer primary key"+ ", " +
                CrimeTable.Cols.NICKNAME + ", " +
                CrimeTable.Cols.REALNAME + ", " +
                CrimeTable.Cols.SEX + ", " +
                CrimeTable.Cols.PHONE + ", " +
                CrimeTable.Cols.EMAILADDRESS + ", " +
                CrimeTable.Cols.PASSWORD + ", " +
                CrimeTable.Cols.FROG + ", " +
                CrimeTable.Cols.DETAILS + ", " +
                CrimeTable.Cols.STDNUM + ")"
        );
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    public static final class  CrimeTable{
        public static final String NAME = "user";

        public static final class Cols{
            public static final String ID = "usrID";
            public static final String NICKNAME = "nickname";
            public static final String REALNAME = "realname";
            public static final String SEX = "sex";
            public static final String AGE = "age";
            public static final String PHONE = "phone";
            public static final String EMAILADDRESS = "email";
            public static final String PASSWORD = "password";
            public static final String FROG = "frog";
            public static final String DETAILS = "details";
            public static final String STDNUM = "stdnum";
        }

    }
}
